package com.study.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.study.pojo.Read;
import com.study.service.ReadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author Miss kun
 * @Date 2020/10/5 19:06
 * @Version 1.0
 */
@Controller
@RequestMapping("/read")
public class ReadController {
    
    @Autowired
    private ReadService readServicea;

    /**
     * 处理返回每日一读的请求
     * @return
     */
    @RequestMapping(value ="/doContent")
    @ResponseBody
    public Read getContent(String id) throws JsonProcessingException {
        System.out.println("getContent----->"+id);
        ObjectMapper mapper = new ObjectMapper();
        Read read = readServicea.getContent();

        /*String str = mapper.writeValueAsString(read);*/
        System.out.println(read);
        return read;
    }
}
